<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>JavaScript 数组迭代</title>
</head>
<body>
<h2>Array.map()</h2>
<p>通过对每个数组元素执行函数来创建新数组。</p>

<p id="demo"></p>

<script>
  var numbers1 = [45, 4, 9, 16, 25];
  var numbers2 = numbers1.map(myFunction);

document.getElementById("demo").innerHTML = numbers2;

function myFunction(value, index, array) {
  return value * 2;
}
</script>
</body>
</html>
<!--90,8,18,32,50-->
<!--
请注意，该函数有 3 个参数：
项目值
项目索引
数组本身
-->